﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace lazy
{
    class Program
    {
        public static int[] red(int Numa, int Numb, int Numc)
        {
            int i;
            int ranNum;
            int Num;
            int[] raa = new int[Numa];
            Random d = new Random();

            for (i = 0; i < Numa; i++)
            {
                ranNum = d.Next(Numb, Numc + 1);
                Num = 0;
                for (int j = 0; j < i; j++)
                {
                    if (raa[j] == ranNum)
                    {
                        Num++;
                    }
                }
                if (Num == 0)
                {
                    raa[i] = ranNum;
                }
                else
                {
                    i = i--;
                }
            }
            return raa;
        }
        static void Main(string[] args)
        {
            //1、生成一个随机整型数组，长度是10，内容是1~10，数组内容不重复
            int Numa = 10;
            int Numb = 1;
            int Numc = 10;

            foreach (int num in red(Numa, Numb, Numc))
            {
                Console.WriteLine(num + " ");
            }

            Console.WriteLine("------------------------------------------------------");
            //2、生成0 - 5之间的随机小数，保留两位小数。
            double st = new double();
            Random rab = new Random();
            for (int i = 0; i < 10; i++)
            {
                st = rab.NextDouble() * 2 + 3;
                Console.WriteLine(st.ToString("f2"));
            }
            Console.WriteLine("------------------------------------------------------");
            //3、生成4 - 7之间的随机小数，保留两位小数。
            double dou = new double();
            Random e = new Random();
            for (int i = 0; i < 10; i++)
            {
                dou = e.NextDouble() * 3 + 4;
                Console.WriteLine(dou.ToString("f2"));
            }
            Console.WriteLine("------------------------------------------------------");
            //4、用户输入邮箱，请验证其合法性。
            while (true)
            {
                Console.WriteLine("请输入邮箱:");
                string email = Console.ReadLine();
                Regex regex = new Regex(@"^(\w6)+(\.\w)*@(\w)+((\.\w+)+)$");
                if (regex.IsMatch(email))
                {
                    Console.WriteLine("输入正确");
                }
                else
                {
                    Console.WriteLine("格式错误");
                }
                break;
            }
            Console.ReadKey();
            Console.WriteLine("------------------------------------------------------");
            //5、用户输入手机号码，请验证其合法性。
            while (true)
            {
                Console.WriteLine("请输入电话号码:");
                string number = Console.ReadLine();
                Regex regex1 = new Regex(@"^1[3456789]\d{9}$");
                if (regex1.IsMatch(number))
                {
                    Console.WriteLine("输入正确");
                }
                else
                {
                    Console.WriteLine("格式错误");
                }
            }
        }
    }
}
